import request from '@/utils/request'

const api = {
  purchaserList: '/purchaseOrder/purchaser',
  orderList: '/purchaseOrder/list',
  supplierList: '/supplier/supplierName',
  auditorList: '/user/auditorList',
  add: '/purchaseOrder/add',
  detail: '/purchaseOrder/detail'
}

// 采购员
export function purchaserList () {
  return request({
    method: 'get',
    url: api.purchaserList
  })
}

// 订单列表
export function orderList (parameter) {
  parameter = parameter || {}
  return request({
    method: 'get',
    url: api.orderList,
    params: {
      order: parameter.order || 'asc',
      page: parameter.page || 1,
      pageSize: parameter.pageSize || 10,
      code: parameter.code || null,
      purchaser: parameter.purchaser,
      status: parameter.status
    }
  })
}

// 供应商列表
export function supplierList () {
  return request({
    method: 'get',
    url: api.supplierList
  })
}

// 审核员列表
export function auditorList () {
  return request({
    method: 'get',
    url: api.auditorList
  })
}

// add
export function add (parameter) {
  return request({
    method: 'post',
    url: api.add,
    data: parameter
  })
}

// detail
export function detail (code) {
  return request({
    method: 'get',
    url: api.detail,
    params: {
      code: code
    }
  })
}
